allow the HITs lifetime to be set

Andrew Cantino 11 年之前
父节点
当前提交
c9b4d1b1f0
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      app/models/agents/human_task_agent.rb

+ 5 - 0
app/models/agents/human_task_agent.rb

@@ -23,6 +23,7 @@ module Agents
23 23
               "title": "Sentiment evaluation",
24 24
               "description": "Please rate the sentiment of this message: '<$.message>'",
25 25
               "reward": 0.05,
26
+              "lifetime_in_seconds": "3600",
26 27
               "questions": [
27 28
                 {
28 29
                   "type": "selection",
@@ -60,6 +61,8 @@ module Agents
60 61
       If all of the `questions` are of `type` _selection_, you can set `take_majority` to _true_ at the top level to
61 62
       automatically select the majority vote for each question across all `assignments`.  If all selections are numeric, an `average_answer` will also be generated.
62 63
 
64
+      `lifetime_in_seconds` is the number of seconds a HIT is left on Amazon before it's automatically closed.  The default is 1 day.
65
+
63 66
       As with most Agents, `expected_receive_period_in_days` is required if `trigger_on` is set to `event`.
64 67
     MD
65 68
 
@@ -109,6 +112,7 @@ module Agents
109 112
             :title => "Sentiment evaluation",
110 113
             :description => "Please rate the sentiment of this message: '<$.message>'",
111 114
             :reward => 0.05,
115
+            :lifetime_in_seconds => 24 * 60 * 60,
112 116
             :questions =>
113 117
               [
114 118
                 {
@@ -233,6 +237,7 @@ module Agents
233 237
       hit = RTurk::Hit.create(:title => title) do |hit|
234 238
         hit.max_assignments = (options[:hit][:assignments] || 1).to_i
235 239
         hit.description = description
240
+        hit.lifetime = (options[:hit][:lifetime_in_seconds] || 24 * 60 * 60).to_i
236 241
         hit.question_form AgentQuestionForm.new(:title => title, :description => description, :questions => questions)
237 242
         hit.reward = (options[:hit][:reward] || 0.05).to_f
238 243
         #hit.qualifications.add :approval_rate, { :gt => 80 }